<include file="__THEME__/header" />
<link href="../Public/css/photo.css" rel="stylesheet" type="text/css" />

<!-- 头部 end -->
<div class="content"><!-- 内容 begin  -->
	<include file="__THEME__/apps" />
	<div class="main"> <!-- 右侧内容 begin  -->

	<div class="page_title"> <!-- page_title begin -->
      <h2><img src="{$APPINFO['APP_ICON']}" />编辑相册“{$album.name}”</h2>
	<div class="c"></div>
</div><!-- page_title end -->

	<div class="photoBox">
		<div class="MenuSub">
		<a href="__APP__/Upload/flash/albumId/{$album.id}">添加新照片</a> ┊ 
		<a href="__APP__/Manage/album_order/id/{$album.id}">照片排序</a> ┊ 
		<a href="__APP__/Manage/album_edit/id/{$album.id}">编辑该相册</a> ┊  
		<a href="javascript:del_album({$album.id})">删除该相册</a> ┊ 
        <a href="__APP__/Index/albums/uid/{$user.id}">返回该相册</a>
        </div>

		<form method="post" action="__URL__/do_update_album" name="do_update_album" onsubmit="return check_form(this);">
		
		<div class="edit_box">

  			<div class="li">
				<div class="c1">专辑名称：</div>
				<div class="c2"><input name="album_name" type="text" class="TextH20" id="album_name" style="width:200px;" onblur="this.className='TextH20'" onfocus="this.className='Text2';change_flag=true;" value="{$album.name}" /></div>
			</div>

			<div class="li">
				<div class="c1">访问权限：</div>
				<div class="c2">
				<select name="album_privacy" id="privacy" onchange="javascript:changePrivacy(this);change_flag=true;">
					<option value="1" <if condition="$album['privacy'] eq 1">selected="selected"</if>>所有人可见</option>
					<option value="2" <if condition="$album['privacy'] eq 2">selected="selected"</if>>仅好友可见</option>
					<option value="3" <if condition="$album['privacy'] eq 3">selected="selected"</if>>仅自己可见</option>
					<option value="4" <if condition="$album['privacy'] eq 4">selected="selected"</if>>凭密码访问</option>
				</select>
				<label><input type="checkbox" name="share" value="1" <eq name="album['share']" value="1">checked="checked"</eq> /> 允许好友分享</label>
				</div>
			</div>
		
			<div class="li" id="need_password" style="display:none;">
				<div class="c1">设置密码：</div>
				<div class="c2">
				<input name="album_privacy_data" value="{$album.privacy_data}" type="text" class="TextH20" id="textfield3" style="width:200px;" onblur="this.className='TextH20'" onfocus="this.className='Text2'" />
				</div>
			</div>
            <div class="clear ml10">
				<br />
				<input type="hidden" name="albumId" value="{$album.id}" />
				<input type="submit" class="btn_b" value="保存{$APPINFO['APP_CNNAME']}信息" />
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				<a href="#" onclick="$('#edit_photos').show()">编辑所有{$APPINFO['APP_CNNAME']}？</a>
			</div>
		</div>

		<div class="edit_list" id="edit_photos" style="display:none;">
			<ul>
			<volist name="photos" id="li">
			<li class="bg04">
				<div class="box">
					<div class="c1"><div class="photo130"><a href="#"><img src="__ROOT__/thumb.php?w=130&h=130&t=f&url={$li.savepath|get_photo_url}{$li.savename}" alt="{$li.name}" /></a></div></div>
					<div class="c2">
						<dl>
							<dt>
							<input value="{$li.name}" name="name[{$li.id}]" type="text" class="TextH20" id="attach_{$li.id}" style="width:200px;" onblur="this.className='TextH20'" onfocus="this.className='Text2';change_flag=true;" />
							</dt>
							<dd><label><input name="album_cover" type="radio" value="{$li.id}" <if condition=" $li['id'] eq $album['coverImageId']">checked='checked'</if> /> 设为该专辑封面</label></dd>
							<dd>转移到：
								<select name="move_to[{$li.id}]" onchange="change_flag=true;">
									<volist name="albumlist" id="al">
										<option value="{$al.id}" <if condition=" $al['id'] eq $album['id']">selected='selected'</if>>{$al.name}</option>
									</volist>
								</select>
							</dd>
						</dl>
					</div>
				</div>
			</li>
			</volist>
			</ul>

			<div class="clear ml10">
				<input type="hidden" name="albumId" value="{$album.id}" />
				<input type="submit" class="btn_b" value="保存{$APPINFO['APP_CNNAME']}信息" />
			</div>

		</div><!-- edit_list end  -->

		
		</form>

	</div>  </div><!-- 右侧内容 end  -->
  <div class="c"></div>
</div><!-- 内容 end -->
<include file="__THEME__/footer" />
<script type="text/javascript">
/** 离开页面提醒 **/
	var change_flag = false;	//修改标识
	var pb_strConfirmCloseMessage	=	"你的修改还没有保存，如果离开本页，修改不会生效！";
	function ConfirmClose() {
		window.event.returnValue = pb_strConfirmCloseMessage;
	}
	function ShowConfirmClose(blnValue) {
		if(blnValue) {
			document.body.onbeforeunload = ConfirmClose;
		} else {
			document.body.onbeforeunload = null;
		}
	}
	//如果页面被修改则弹出提醒
	if(change_flag){
	//	ShowConfirmClose(true);
	}
/** 离开页面提醒 **/

//初始化密码框
if($('#privacy').val()==4){
	$('#need_password').show();
}

//显示密码框
function changePrivacy(obj){
	if(obj.value==4){
		$('#need_password').show();
	}else{
		$('#need_password').hide();
	}
}

//表单验证
function check_form(obj){
	if(obj.album_name.value==''){
		alert('专辑名字不能为空');
	}

	//提交表单不弹出提醒
	//ShowConfirmClose(false);
	return true;
}

//删除相册
function del_album(){
	ymPrompt.confirmInfo({message:'删除相册同时会删除所有照片，你确定要删除这个相册么？',handler:ajax_delete_album});
}
function ajax_delete_album(e){
	var album_id	=	'{$album.id}'; 
	if(e=='ok'){
		$.post(APP+'/Manage/delete_album',{ajax:1,id:album_id},function(data){
			if(data==1){
				//设置数据
				parent.location.href = APP+'/Index/albums/uid/{$mid}';
			}else{
				ymPrompt.close();
				ymPrompt.errorInfo('删除失败！');
			}
		});
	}else{
		ymPrompt.close();
	}
	return false;
}
</script>